Skip to content

Encrypted improvements #619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: develop
Choose a base branch
from
Open

Encrypted improvements #619

wants to merge 20 commits into from

Conversation

will-v-pi
Copy link
Contributor

@will-v-pi will-v-pi commented Feb 24, 2025

This adds a self-decrypting binary to demonstrate raspberrypi/pico-sdk#2315 and raspberrypi/picotool#207 - it requires both of those and raspberrypi/pico-sdk#2182 so should only be merged once those have been merged

Also fixes #613 in passing, as that is now handled by picotool.

@will-v-pi will-v-pi added this to the 2.1.2 milestone Feb 24, 2025
@will-v-pi will-v-pi linked an issue Feb 26, 2025 that may be closed by this pull request
Update CMake tooling to use 128 byte key files (a 4-way share of the 32 byte key).
Also temporarily update the enc_bootloader to deshare this key - the actual fix will need to be in aes.S.
Add data_max_size to prevent overwriting the bootloader with data from flash
Also shrink the space allocated for the bootloader to 32K (plus 8K scratch)
This is not necessary anymore, now picotool writes the AES key to otp json files

Fixes #613
CK_JITTER is removed as the enc_bootloader runs from XOSC not ROSC
This includes the changes from #553
This is useful for testing decryption with large files
@will-v-pi will-v-pi force-pushed the encrypted-improvements branch from 6ca5a1c to bde13d6 Compare March 26, 2025 16:05
Add self check (1 == 1), which is only performed on first boot
will-v-pi added a commit to raspberrypi/picotool that referenced this pull request Apr 22, 2025
Comment on lines +9 to +13
The AES key is stored as a 4-way share in a 128 byte binary file - you can create one with

```bash
dd if=/dev/urandom of=privateaes.bin bs=1 count=128
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it might be worth changing the privateaes.bin filename to make it clearer that it's a key-share and not just a raw AES key? 🤔

@@ -1,45 +1,31 @@
/* MEMORY LAYOUT ASSUMPTIONS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this aes.S the same as the one in raspberrypi/picotool#207 ?
(And if so, do we have any mechanism for ensuring that they stay in sync?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes (although hasn't been updated with some of the latest changes)

No mechanism to keep them in sync, but the copy in picotool is the authoritative copy so changes should always be made there and copied across

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the picotool CI is now also building pico-examples, perhaps the picotool CI could also check that these files in the two repos match? (or perhaps it's very unlikely that this file will change in future, so perhaps that'd be overkill)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds like a good idea, I will add that

Comments and readme
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

otp.json in encrypted example breaks clean build
2 participants